package com.zhangxu.microservice.system.biz.convert;

import com.zhangxu.microservice.system.biz.dto.RoleResourceDTO;
import com.zhangxu.microservice.system.dao.entity.RoleResourceDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 角色资源权限关联对象转换接口
 */
@Mapper(componentModel = "spring")
public interface RoleResourceConverter {

    /**
     * RoleResourceDO 转 RoleResourceDTO
     *
     * @param roleResourceDO 角色资源权限关联实体
     * @return 角色资源权限关联DTO
     */
    @Mapping(target = "id", source = "id")
    @Mapping(target = "roleId", source = "roleId")
    @Mapping(target = "resourceCode", source = "resourceCode")
    @Mapping(target = "createTime", source = "createTime")
    @Mapping(target = "updateTime", source = "updateTime")
    @Mapping(target = "role", ignore = true)
    @Mapping(target = "resource", ignore = true)
    RoleResourceDTO toRoleResourceDTO(RoleResourceDO roleResourceDO);

    /**
     * RoleResourceDTO 转 RoleResourceDO
     *
     * @param roleResourceDTO 角色资源权限关联DTO
     * @return 角色资源权限关联实体
     */
    RoleResourceDO toRoleResourceDO(RoleResourceDTO roleResourceDTO);
}